#region Usings
using System;
using System.Collections.Generic;
using System.Linq;

using BK.Model;
using BK.Repositories.Abstract;

using Lib.ApplicationBlocks.DbBlocks.Membership;
#endregion

namespace BK.Repositories.EF
{
    public class UsersRepository : BaseRepository<User>, IUsersRepository
    {
        #region IUsersRepository Members
        public UsersRepository(BkDataContext dataContext) : base(dataContext)
        {
        }

        public User GetByEmail(string email)
        {
            return ObjectSet.Where(user => (user.Email == email)).SingleOrDefault();
        }

        public User Login(string email, string password)
        {
            return ObjectSet.Where(user => (user.Email == email) && (user.Password == password)).SingleOrDefault();
        }

        public CultureAndLocal GetCulatuCultureAndLocal(string userName)
        {
            throw new NotImplementedException();
        }

        IMembership IMgrMemberships.Load(string login, string password)
        {
            return Login(login, password);
        }

        IMembership IMgrMemberships.Load(string login)
        {
            return GetByEmail(login);
        }

        IMembership IMgrMemberships.Save(IMembership membership)
        {
            Save((User) membership);
            return membership;
        }

        public void SetCulture(string userName, CultureAndLocal cultureAndLocal)
        {
            throw new NotImplementedException();
        }
        #endregion
    }
}